<?php
session_start();
if(empty($_SESSION["id"])) header("Location:index.php");

include("/inc/usuario.class.php");

	$usuario = new usuario();
	$resultado = $usuario->BuscaUsuario($_SESSION["id"]);
	while($row = mysql_fetch_array($resultado)){
		$unombre = $row['usuario_nombre'];
		$usrn = $row['usuario_username'];
		$umail = $row['usuario_email'];
		$udir = $row['usuario_direccion'];
		$upass = $row['password'];
		$utel = $row['usuario_telefono'];
		$ucd = $row['ciudad_id'];
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">

<!--  Version: Multiflex-3 Update-7 / Layout-1             -->
<!--  Date:    January 15, 2007                            -->
<!--  Author:  Wolfgang                                    -->
<!--  License: Fully open source without restrictions.     -->
<!--           Please keep footer credits with a link to   -->
<!--           Wolfgang (www.1-2-3-4.info). Thank you!     -->

<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <link rel="stylesheet" type="text/css" media="screen,projection,print" href="./css/layout1_setup.css" />
  <link rel="stylesheet" type="text/css" media="screen,projection,print" href="./css/layout1_text.css" />
  <title>GiveAway</title>
</head>

<!-- Global IE fix to avoid layout crash when single word size wider than column width -->
<!--[if IE]><style type="text/css"> body {word-wrap: break-word;}</style><![endif]-->

<body>
  <!-- Main Page Container -->
  <div class="page-container">

   <!-- For alternative headers START PASTE here -->

    <!-- A. HEADER -->      
    <div class="header">
      
      <!-- A.1 HEADER TOP -->
      <div class="header-top">
        
        <!-- Sitelogo and sitename -->
        <a class="sitelogo" href="#" title="Home"></a>
        <div class="sitename">
          <h1><a href="index2.php" title="Home">GiveAway</a></h1>
        </div>
        <!-- Navigation Level 1 -->
        <div class="nav1">
          <ul>
            <li><a href="index2.php" title="Go to Start page">Home</a></li>
            <li><a href="contacto.php">Cont&aacute;ctanos</a></li>
          </ul>
        </div>              
      </div>
      
      <!-- A.2 HEADER MIDDLE -->
      <div class="header-middle">    
   
        <!-- Site message -->
        <div class="sitemessage">
          <h1>COMPARTE</h1>
          <h2>Intercambio y donación de productos</h2>
          <h3><a href="#">&rsaquo;&rsaquo;&nbsp;M&aacute;s detalles</a></h3>
        </div>        
      </div>
      
      <!-- A.3 HEADER BOTTOM -->
      <div class="header-bottom">
      
        <!-- Navigation Level 2 (Drop-down menus) -->
        <div class="nav2">
	
          <!-- Navigation item -->
          <ul>
            <li><a href="index2.php">Home</a></li>
          </ul>
          
          <!-- Navigation item -->
          <ul>
            <li><a href="productos.php">Mis Productos</a></li>
          </ul>          

          <!-- Navigation item -->
          <ul>
            <li><a href="navegar.php">Productos Disponibles</a></li>
          </ul>
		<ul>
            <li><a href="perfil.php">Configuraci&oacute;n</a></li>
          </ul>
		  <ul>
            <li><a href="logout.php">Salir</a></li>
          </ul>
        </div>
	  </div>

      <!-- A.4 HEADER BREADCRUMBS -->

      <!-- Breadcrumbs -->
      <div class="header-breadcrumbs">
      </div>
    </div>

   <!-- For alternative headers END PASTE here -->

    <!-- B. MAIN -->
    <div class="main">
  
      <!-- B.1 MAIN CONTENT -->
      <div class="main-content">
        
        <!-- Pagetitle -->
        <h1 class="pagetitle">Mi Perfil</h1>

        <!-- Content unit - One column -->
        <h1 class="block">Editar Perfil</h1>
        <div class="column1-unit">
            <p>
				<h2><?php 
			if(isset($_GET['e'])){
				if($_GET['e'] == 1) echo 'No se pudo editar tu password';
				else if ($_GET['e'] == 2) echo 'Las passwords no coinciden';
				else if ($_GET['e'] == 3) echo 'No se pudieron editar tus datos';
				else if ($_GET['e'] == 4) echo 'Edici&oacute;n exitosa';
			}
		?></h2>
				<form method="post" action="editar_perfil.php" enctype="multipart/form-data">
					<input type="hidden" name="pid" value="<?php echo $_GET['pid']; ?>">
					<table>
						<tr>
							<td>Nombre</td>
							<td><?php echo $unombre;?></td>
							<td><input name="unombre" type="text" value="<?php echo $unombre; ?>"/></td>
						</tr>
						<tr>
							<td>Username</td>
							<td><?php echo $usrn; ?></td>
							<td><input name="usrn" type="text" value="<?php echo $usrn; ?>"/></td>
						</tr>
						<tr>
							<td>E-mail</td>
							<td><?php echo $umail; ?></td>
							<td><input name="umail" type="text" value="<?php echo $umail; ?>"/></td>
						</tr>
						<tr>
							<td>Direcci&oacute;n</td>
							<td><?php echo $udir; ?></td>
							<td><input name="udir" type="text" value="<?php echo $udir; ?>"/></td>
						</tr>
						<tr>
							<td>Ciudad</td>
							<td><?php 
								if($ucd == 1) echo 'Santiago';
								else if($ucd == 2) echo 'Valparaiso';
								else if($ucd == 3) echo 'Viña del Mar';
							?></td>
							<td><SELECT NAME="ucd" SIZE="1"> 
												<OPTION VALUE="1">Santiago</OPTION> 
												<OPTION VALUE="2">Valparaiso</OPTION> 
												<OPTION VALUE="3">Viña del Mar</OPTION> 
												</SELECT></td>
						</tr>
						<tr>
							<td>Telefono</td>
							<td><?php echo $utel; ?></td>
							<td><input name="utel" type="text" value="<?php echo $utel; ?>"/></td>
						</tr>
						<tr>
							<td colspan="3" style="text-align: center;"><input type="submit" value="Editar"/></td>
						</tr>
					</table>
				</form>
			</p>
			<p>
				<form  method="post" action="editar_pass.php" enctype="multipart/form-data">
					<table>
						<tr>
							<td>Password</td>
								<td>Nueva <input name="upass1" type="password" /></td>
								<td>Confirmar <input name="upass2" type="password" /></td>
						</tr>
						<tr>
							<td colspan="3" style="text-align: center;"><input type="submit" value="Editar"/></td>
						</tr>
					</table>
				</form>
			</p>
        </div>          
        <hr class="clear-contentunit" />
      </div>
    </div>
      
    <!-- C. FOOTER AREA -->      

    <div class="footer">
      <p>Copyright &copy; 2011 GiveAway | All Rights Reserved</p>
      <p class="credits">Design by <a href="http://www.1-2-3-4.info/" title="Designer Homepage">Wolfgang</a></p>
    </div>      
  </div> 
  
</body>
</html>



